package validate

import (
	"fmt"
	"sigs.k8s.io/yaml"
)

func getVersion(group, version string) string {
	if group == "" {
		return version
	}

	return fmt.Sprintf("%s/%s", group, version)
}

func fromYAML(config []byte) (map[string]interface{}, error) {
	var i map[string]interface{}

	if err := yaml.Unmarshal(config, &i); err != nil {
		return nil, fmt.Errorf("failed to unmarshal yaml rego.parameters with error: %v. source: %q", err, config)
	}
	return i, nil
}
